package com.timous.tree;

import java.util.Stack;

public class middle {
    public static void middleMethod(TreeNode root){
        Stack<TreeNode> s  = new Stack<>();
        TreeNode node = root;
        while (node != null){
            if (node != null){
                s.push(node);
                node = node.left;
            }else {
                TreeNode l = s.pop();
                System.out.println(l.val);
                node = node.right;
            }
        }
    }

}
